/*
 * Layout.h
 *
 *  Created on: Mar 23, 2011
 *      Author: hxu
 */

#ifndef LAYOUT_H_
#define LAYOUT_H_

#include<sstream>
#include<fstream>
#include<iostream>
#include<vector>
//#include "Segment.h"
#include "Network.h"
#include "Toolset.h"
#include "Btree.h"
//#include "Solution.h"

namespace Cxuh{

template <class Type> class Layout {
	// Type could be int or float
public:
	Layout();
	Layout(std::ifstream& setupstream, std::ifstream & iclayout);
	std::vector<Cxuh::Btree* > getTrees();
	virtual ~Layout();
	void CTS3D();	// synthesize all trees with MMM 3D
	void CTS();	// synthesize all trees with MMM 2D
	void printPaths (std::ostream& out);		// print the paths to the sinks

	static void extractPar(std::ifstream& fs); // extract parameter from setup files
	static void parseLine(std::string& strline);
private:
	std::vector<Cxuh::Btree* > trees;	// vector of networks in the layout
	int treenum;	// # of networks
	Cxuh::Segment<Type>* curSeg;	// current segment
	BtreeNode* curNode; // current node
	virtual void StrTr(const std::string&); // translate a string
	//virtual Cxuh::Segment<Type>* Str2Seg(std::istringstream&) throw(int);	// string to segment
	template<class TT> friend std::ostream& operator << (std::ostream& out, Layout<TT>& obj);
};

}
#endif /* LAYOUT_H_ */

